from django.db import models


# Create your models here.

class User(models.Model):
    username = models.CharField(max_length=50)
    password = models.CharField(max_length=50)
    # address = models.CharField(max_length=50)
    age = models.IntegerField(default=10)

    class Meta:
        db_table = 'user'


class Cclass(models.Model):
    name = models.CharField(max_length=20, verbose_name='年级')
    types = models.IntegerField(verbose_name='状态',unique=True)  # 1小班，2中班，3大班

    class Meta:
        db_table = 'class'
        verbose_name = '年级表'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class Cbanji(models.Model):
    name = models.CharField(max_length=20, verbose_name='班级')
    cla = models.ForeignKey(Cclass, on_delete=models.CASCADE, verbose_name='年级',related_name='banji')  # 1小班，2中班，3大班

    class Meta:
        db_table = 'banji'
        verbose_name = '班级'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class Cuser(models.Model):
    name = models.CharField(max_length=20, verbose_name='名称')
    username = models.CharField(max_length=100, verbose_name='用户名')
    password = models.CharField(max_length=100, verbose_name='密码')
    cla = models.ForeignKey(Cclass, on_delete=models.CASCADE, verbose_name='年级')  # 1小班，2中班，3大班

    class Meta:
        db_table = 'cuser'
        verbose_name = '小朋友'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
